<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title}</title>
    <link rel="stylesheet" href="${basePath}/static/bootstrap/css/bootstrap.css"/>
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	 <script type="text/javascript" src="${basePath}/static/js/echatrs/echarts.min.js"></script>
    <script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
	<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/qualityNav.jsp"%>
    </div>
    <div class="list_NR">
        <div class="loc">
            <h3 style="margin:0">缺陷统计</h3>
        </div>
        <div class="list_con_table">
           <div class="search_table">
            <input type="hidden" id="qualityStatus" value="${medicalSearchVO.qualityStatus}">
                <ul class="clearfix" style="margin-bottom:0;">
                            <li class="Label_1" style="width:11%">出院日期：&nbsp;</li>
               <li class="Label_2" style="width:27%;">
                   <input style="width:43%;" class="input_box" id="outHospitalStartDate" value='${startTime}' onFocus="WdatePicker()" type="text" > 
                   - <input style="width:43%" class="input_box" id="outHospitalEndDate"  value='${endTime }' onFocus="WdatePicker()" type="text" >
               </li>
                <li class="Label_1" style="width:11%">出院科室：&nbsp;</li>
               <li class="Label_2" >      
               	<select class="input_box" id="outHospitalOfficeId">
               		<option value="">请选择</option>
               		<c:forEach var="office" items="${officeList }"> 
            
               			
               			<c:choose>
							<c:when test="${medicalSearchVO.outHospitalOfficeId == office.id }">
										<option selected="selected" value="${office.id }">${office.name}</option>
									</c:when>
									<c:otherwise>
										<option value="${office.name }">${office.name}</option>
									</c:otherwise>
								</c:choose>
               			
               		</c:forEach>
                	
                	</select>
                </li>
               <li class="Label_1" style="width:11%">ID号：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  id="mrId" value='${medicalSearchVO.mrId }' />
               </li>
               
             
               <li class="Label_1" style="width:11%">身份证号：&nbsp;</li>
               <li class="Label_2" style="width:27%;"><input class="input_box" type="text" id="idCard"  value='${medicalSearchVO.idCard }' />          	 
               </li>
                 <li class="Label_1" style="width:11%">住院次数：&nbsp;</li>
               <li class="Label_2">
               	<input class="input_box" type="text"  id="visitNumber" value='' />
               </li>
             
                <li class="Label_1" style="width:11%">姓名：&nbsp;</li>
                <li class="Label_2"><input class="input_box" type="text" id="name"  value='' />          	 
             
                </li> 
                    <li class="Label_5">
                        <div class="right" style="text-align:right">
                            <a id="Add" onclick="init()">查询</a>
                             <a class="int" onclick="exportExcel()">导出</a>
                            
                            
                        </div>
                    </li>
                </ul>
            </div> 
             <table class="Search_tableList" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="tdLabel_4">科室名称</td>
                    <td class="tdLabel_4">扣分项总量</td>
                  
                    <td class="tdLabel_4">扣分项</td>
                    <td class="tdLabel_4">扣分项数量</td>
                    <td class="tdLabel_4">识别码</td>
                    <td class="tdLabel_4">住院次数</td>
                     <td class="tdLabel_4">错误描述</td>
             
          
                    <td class="tdLabel_4">操作</td>
                </tr>
                <tr id="loading" style="height:50px;display:none">
	             	<td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	            </tr>
                <tbody id="tbody">
                	 <!-- <tr>
	                    <td class="tdLabel_5" rowspan="4">扣分项</td>
	                    <td class="tdLabel_5" rowspan="4">错误数量</td>
	                  
	                    <td class="tdLabel_5" rowspan="2">科室名称</td>
	                    <td class="tdLabel_5" rowspan="2">错误数量</td>
	                    <td class="tdLabel_5">识别码</td>
	                    <td class="tdLabel_5">住院次数</td>
	                     <td class="tdLabel_5">错误数</td>
	          
	                    <td class="tdLabel_5">操作</td>
                	</tr>
                	 <tr>
	                  
	                    <td class="tdLabel_5">识别码</td>
	                    <td class="tdLabel_5">住院次数</td>
	                     <td class="tdLabel_5">错误数</td>
	          
	                    <td class="tdLabel_5">操作</td>
                	</tr>
                	 <tr>
	                  
	                    <td class="tdLabel_5" rowspan="2">科室名称</td>
	                    <td class="tdLabel_5" rowspan="2">错误数量</td>
	                    <td class="tdLabel_5">识别码</td>
	                    <td class="tdLabel_5">住院次数</td>
	                     <td class="tdLabel_5">错误数</td>
	          
	                    <td class="tdLabel_5">操作</td>
                	</tr>
                	 <tr>
	                  
	                   
	                    <td class="tdLabel_5">识别码</td>
	                    <td class="tdLabel_5">住院次数</td>
	                     <td class="tdLabel_5">错误数</td>
	          
	                    <td class="tdLabel_5">操作</td>
                	</tr> -->
                </tbody>
   
            </table>
        </div>
      
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>
<!--JS部分-->

<script>


  function exportExcel(){
	  var visitNumber=$("#visitNumber").val();
  	  var  name=$("#name").val();
  	  var idCard=$("#idCard").val();
      var  outHospitalStartDate=$("#outHospitalStartDate").val();
  	  var  outHospitalEndDate=$("#outHospitalEndDate").val();
  	  var  mrId=$("#mrId").val();
  	  var  outHospitalOfficeId=$("#outHospitalOfficeId").val();
		
      if((visitNumber==null||visitNumber=="")&&(name==null||name=="")&&(idCard==""||idCard==null)&&(mrId==""||mrId==null)&&
				(outHospitalOfficeId==""||outHospitalOfficeId==null)&&(outHospitalStartDate==""||outHospitalStartDate==null)&&(outHospitalEndDate==""||outHospitalEndDate==null)
				){
			layer.alert('请至少输入一个查询条件!', {icon: 0});
			return;
	   }
      
      window.location.href="${basePath}/quality/exportQualityErrorExcel?name="+name+"&idCard="+idCard+"&startTime="+outHospitalStartDate+"&endTime="+outHospitalEndDate+"&mrId="+mrId+"&outHospitalOffice="+outHospitalOfficeId+"";     
  }

    
    
    function init(){
    	 
    	var visitNumber=$("#visitNumber").val();
    	var  name=$("#name").val();
    	var idCard=$("#idCard").val();
    	var  outHospitalStartDate=$("#outHospitalStartDate").val();
    	var  outHospitalEndDate=$("#outHospitalEndDate").val();
    	var  mrId=$("#mrId").val();
    	var  outHospitalOfficeId=$("#outHospitalOfficeId").val();
		
		if((visitNumber==null||visitNumber=="")&&(name==null||name=="")&&(idCard==""||idCard==null)&&(mrId==""||mrId==null)&&
				(outHospitalOfficeId==""||outHospitalOfficeId==null)&&(outHospitalStartDate==""||outHospitalStartDate==null)&&(outHospitalEndDate==""||outHospitalEndDate==null)
				){
			layer.alert('请至少输入一个查询条件!', {icon: 0});
			return;
		}
    	jQuery.support.cors = true;
    	$.ajax({
    		type:'post',
    		//url:"${basePath}/quality/queryQualityDefect",
    		url:"${basePath}/quality/queryQualityDefect",
    		data:{visitNumber:visitNumber,
    			name:name,
    			idCard:idCard,
    			startTime:outHospitalStartDate,
    			endTime:outHospitalEndDate,
    			mrId:mrId,
    			outHospitalOffice:outHospitalOfficeId
    			 },
    		beforeSend:function(){
    	 		$("#tbody").html("");
    	 		/* $("#loading").show(); */
    	 	},
    		success:function(data){
    			/*  console.log(data);
    			return;  */
    			if(data.success){
    				var list =data.data;
    				var html = "";
    				for(var i=0;i<list.length;i++){
    					var obj = list[i];
    					html+=" <tr> "+
    	                   	  "	 <td class='tdLabel_5' rowspan='"+obj.totalNum+"'>"+obj.officeName+"</td>"+
    	                   	  "	 <td class='tdLabel_5' rowspan='"+obj.totalNum+"'>"+obj.totalNum+"</td>";
                        var secondList = obj.officeProject;
                        for(var j=0;j<secondList.length;j++){
                        	var secondObj = secondList[j];
                       	 
                        	if(j==0){
                        		html+="<td class='tdLabel_5' rowspan='"+secondObj.projectNum+"'>"+secondObj.projectName+"</td>"+
  	                    	 		  "<td class='tdLabel_5' rowspan='"+secondObj.projectNum+"'>"+secondObj.projectNum+"</td>";
                        	}else{
                        		html+="<tr><td class='tdLabel_5' rowspan='"+secondObj.projectNum+"'>"+secondObj.projectName+"</td>"+
                    	 		  "<td class='tdLabel_5' rowspan='"+secondObj.projectNum+"'>"+secondObj.projectNum+"</td>";
                        	}
                    
    	                    var thirdList = secondObj.mrProject;
    	                     for(var k =0;k<thirdList.length;k++){
    	                    	var thirdObj = thirdList[k];
    	                    	
    	        
    	                    	
    	                    	if(k==0){
    	                    		html+="<td class='tdLabel_5'>"+thirdObj.mrId+"</td>"+
    	    	                          " <td class='tdLabel_5'>"+thirdObj.visitNumber+"</td>"+
    	    	                          " <td class='tdLabel_5'>"+thirdObj.med_control_desc+"</td>"+
    	    	                          "  <td class='tdLabel_5' ><a target='_blank' href='${basePath}/quality/updateMedQua?firstGuid="+thirdObj.firstGuid+"' class='int'>查看</a></td></tr>";
  		                   		  		 
    	                    	}else{
    	                    		html+="<tr><td class='tdLabel_5'>"+thirdObj.mrId+"</td>"+
	    	                         " <td class='tdLabel_5'>"+thirdObj.visitNumber+"</td>"+
	    	                         " <td class='tdLabel_5'>"+thirdObj.med_control_desc+"</td>"+
	    	                          "  <td class='tdLabel_5' ><a href='${basePath}/quality/updateMedQua?firstGuid="+thirdObj.firstGuid+"' target='_blank' class='int'>查看</a></td></tr>";
    	                    	}
    	                    	
    	                    } 
    	                    
    	                     
    	               
    	                    
                        }
                        
                        $("#tbody").html(html);
    					
    				}
    			}else{
    				 layer.alert("查询失败!", {icon: 5});
    			}
    			
    		},
    		error:function(data){
    			 $("#loading").hide();
    			 layer.alert("服务器错误", {icon: 5});
    		}
    	})
    }

    
    

    
   

</script>
</body>
</html>
<%-- <!--头部-->
	<%@include file="/WEB-INF/templates/common/header.jsp"%>
	<!------导航条-->
	<%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div class="list_DH">
        <%@include file="/WEB-INF/templates/common/qualityNav.jsp"%>
    </div>
    <div class="list_NR" style="height:100%">
        <div class="loc">
            <h3 style="margin:0;font-size:16px">病案缺陷</h3>
        </div>
        <div class="list_con_table">
            <div class="search_table" style="height:70px">
                <ul class="clearfix">
                    <li class="Label_1">质控日期：&nbsp;</li>
                    <li class="Label_4" style="text-align: left;padding-left:4px;">
                    <input class="input_box" style="width:150px;" type="text"  name='startTime' id='startTime' value='' onFocus="WdatePicker()" /><span>&nbsp;-&nbsp;</span>
                    <input class="input_box" type="text" style="width:150px;"  name='endTime' id='endTime' value='' onFocus="WdatePicker()" /></li>
                    <li class="Label_5">
                        <div class="right" style="text-align:right">
                            <a  onclick="getMedQuaTotal()">查询</a>  
                         	<!-- <a  onclick="exportExcel()">导出</a> -->
                        </div>
                    </li>
                  
                </ul>
            </div> 
        </div>
         <div id="container"  style="height:400px;width:100%;margin-top:83px"></div>
        <!-- <div class="pageList">
            <ul class="pagination clearfix" id="page_plus"></ul>
            <div class="pagination">
                <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
            </div>
        </div> -->
    </div>
</div>
<!------页脚部分--------->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>


       <script type="text/javascript">
  
       
       function getMedQuaTotal(){
		var startTime=$("#startTime").val();
		var endTime=$("#endTime").val();
		if(!startTime && !endTime){
			layer.alert("请输入查询条件!", {icon: 0});
			return;
		}
		$.ajax({
			type:"post",
			url:"${basePath}/quality/queryQualityDefect",
			data:{startTime:startTime,endTime:endTime},
			success:function(data){
				console.log(data)
				if(data.success){
					
					var totalSize=data.data.totalSize;
					if(totalSize==null || totalSize==undefined || totalSize==0 ){
						layer.alert("查询数据为空!", {icon: 1});
						return;
					}
					var dataMap= data.data;
					ecartsDom(dataMap);
					
				}else{
					layer.alert("查询失败!", {icon: 0});
					return;
				}
			}
		});
       }
				
       
       
      function ecartsDom(dataList){
    	  var dom = document.getElementById("container");
    	  $("#container").height(dataList.totalSize*80);
    	  var myChart = echarts.init(dom);
    	  var app = {};
    	  option = null;
    	  app.title = '堆叠条形图';

    	  option = {
    	      tooltip : {
    	          trigger: 'axis',
    	          axisPointer : {            // 坐标轴指示器，坐标轴触发有效
    	              type : 'line'        // 默认为直线，可选为：'line' | 'shadow'
    	          }
    	      },
    	      legend: {
    	          data: ['病案首页', '病历书写项目','入院记录项目','病程记录项目','知情同意书项目','医嘱单及辅助检查项目']
    	      },
    	      grid: {
    	          left: '3%',
    	          right: '4%',
    	          bottom: '3%',
    	          containLabel: true
    	      },
    	      xAxis:  {
    	          type: 'value'
    	      },
    	      yAxis: {
    	          type: 'category',
    	          data: dataList.officeList
    	      },
    	      series: [
    	          {
    	              name: '病案首页项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.oneList
    	          },
    	          {
    	              name: '病历书写项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.twoList
    	          },
    	          {
    	              name: '入院记录项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.threeList
    	          },
    	          {
    	              name: '病程记录项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.fourList
    	          },
    	          {
    	              name: '知情同意书项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.fiveList
    	          },
    	  		 {
    	              name: '医嘱单及辅助检查项目',
    	              type: 'bar',
    	              stack: '总量',
    	              label: {
    	                  normal: {
    	                      show: true,
    	                      position: 'insideRight'
    	                  }
    	              },
    	              data: dataList.sixList
    	          }
    	      ]
    	  };;
    	  if (option && typeof option === "object") {
    	      myChart.setOption(option, true);
    	  }
      } 
       

       </script>

</body>
</html> --%>